package com.stars.module.setting.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.stars.module.setting.entity.SystemSetting;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SystemSettingMapper extends BaseMapper<SystemSetting> {

    @Select("SELECT * FROM STAR_SYSTEM_SETTING WHERE TYPE = '1'")
    List<SystemSetting> loadAllSettings ();

    @Select("SELECT * FROM STAR_SYSTEM_SETTING WHERE TYPE = '2' AND CREATEUNITID = #{unitId}")
    List<SystemSetting> loadAllUnitSettings (String unitId);

    @Select("SELECT * FROM STAR_SYSTEM_SETTING WHERE TYPE = '3' AND CREATEUSERID = #{userId}")
    List<SystemSetting> loadAllUserSettings (String userId);

    @Select("SELECT * FROM STAR_SYSTEM_DEFINE WHERE TYPE = #{type} ORDER BY SHOWORDER")
    List<SystemSetting> loadAllDefine (String type);

    @Delete("DELETE FROM STAR_SYSTEM_SETTING WHERE TYPE = '1'")
    void deleteAllSetting();

    @Delete("DELETE FROM STAR_SYSTEM_SETTING WHERE TYPE = '2' AND CREATEUNITID = #{unitId}")
    void deleteAllUnitSetting (String unitId);

    @Delete("DELETE FROM STAR_SYSTEM_SETTING WHERE TYPE = '3' AND CREATEUSERID = #{userId}")
    void deleteAllUserSetting (String userId);
}
